package cn.lzm.basic.controller;

import cn.lzm.basic.dto.EmailCodeDto;
import cn.lzm.basic.service.IRegisterService;
import cn.lzm.basic.util.AjaxResult;
import cn.lzm.user.dto.EmailRegisterDto;
import cn.lzm.user.dto.PhoneRegisterDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("register")
public class RegisterController {
    @Autowired
    private IRegisterService registerService;
    @RequestMapping("/phone")
    public AjaxResult phoneRegister(@RequestBody @Valid PhoneRegisterDto dto){
        registerService.phoneRegister(dto);
        return AjaxResult.me().success();
    }

    @RequestMapping("/email")
    public AjaxResult emailRegister(@RequestBody @Valid EmailRegisterDto dto){
        registerService.emailRegister(dto);
        return AjaxResult.me().success();
    }
}
